package com.example.androidclassseven;

import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;
import android.widget.Toast;

import java.util.Calendar;


public class MyDataDialog extends DialogFragment implements android.app.DatePickerDialog.OnDateSetListener {

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        Calendar instance = Calendar.getInstance();
        int year = instance.get(Calendar.YEAR);
        int mon = instance.get(Calendar.MONDAY);
        int day = instance.get(Calendar.DATE);
        android.app.DatePickerDialog datePickerDialog = new android.app.DatePickerDialog(getActivity(), this, year, mon, day);
        return datePickerDialog;
    }

    //实现的方法
    @Override
    public void onDateSet(DatePicker datePicker, int year, int mon, int day) {
        Toast.makeText(getContext(), year + "/" + mon + "/" + day, Toast.LENGTH_SHORT).show();
    }
}